home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / util / cli / headtail.readme < prev    next >
Encoding:
Text File  |  1994-01-30  |  3.1 KB  |  104 lines

  1. Short: unix-style head/tail, better than others
  2.  
  3. Well, yes, they are, to be honest.  I haven't yet seen a "head" or
  4. "tail" program for AmigaDOS which even implemented the lbc stuff in
  5. the "real" tail for Unix.  Though numerous, all the tails I've seen
  6. can only do lines, with one exception that could do chars.  This last,
  7. however, couldn't read from standard input.  I found my work severely
  8. limited; I maintain that head and tail are among the most useful tools
  9. in the unix environment.
  10.  
  11. So here's a tail program that reads any number of files, or standard
  12. input; if more than one file is read, the start of each file is noted
  13. in stderr, with files sections themselves going to stdout.  Unlike
  14. most other Amiga tails I've seen, headtail can do head-relative or
  15. tail-relative tailing by using "+" or "-" before the count.  E.g., for
  16. the file:
  17.  
  18. Start
  19. Line1
  20. Line2
  21.  
  22. Line4
  23. End
  24.  
  25. > tail +3l <file>
  26.  
  27. would report:
  28. Line2
  29.  
  30. Line4
  31. End
  32.  
  33. while
  34.  
  35. > tail -3l <file>
  36.  
  37. would report:
  38.  
  39. Line4
  40. End
  41.  
  42. You see?
  43.  
  44. Character units (specifiec with "c" in place of "l") work similarly;
  45.  
  46. > tail -7 <file>
  47.  
  48. on the above example file would return:
  49. e4
  50. End
  51.  
  52. (You must remember to count line feeds.)
  53.  
  54. Blocks work the same way; a block is equivalent to 512 characters.
  55. You can change this in the source code to 488 if you use an OFS
  56. system; it will more accurately reflect your actual file structure.
  57.  
  58.  
  59.  
  60. AND, AS AN ADDED BONUS:
  61.  
  62. The Unix "head" is included, too.  Soaring above even Unix head,
  63. however, headtail's head will take all the same arguments as tail.
  64. The only difference in meaning is that "+" and "-" swap places; i.e,
  65.  
  66. Program    Sign    Meaning
  67. tail    +    count is relative to start of file
  68. tail    -    count is relative to end of file
  69. head    +    count is relative to end of file
  70. head    -    count is relative to start of file
  71.  
  72. Thus Unix-formatted commands work with headtail, but there are more
  73. option if you want them.
  74.  
  75.  
  76.  
  77. BUT WAIT -- THERE'S EVEN MORE!
  78.  
  79. As a special for Kickstart v36+ users, head and tail are included as
  80. one program.  It works like compress: there's one program, and its
  81. function is determined by its name.  Basic installation consists of
  82. copying tail to somewhere in your path, and making a link from "head"
  83. to "tail".  (You could, of course, do it the other way.)  If called as
  84. "head", the program performs head stuff; if called as "tail", it does
  85. tail stuff.  If called something else, it still does tail stuff.
  86.  
  87. If you don't have 2.0, you should.  But you can still use headtail by
  88. just copying the program to "head", then to "tail".  They don't have
  89. to be links, but it saves disk space if they are.
  90.  
  91.  
  92.  
  93. HeadTail was written by David Champion some time in July - August
  94. 1992.  It was compiled with Matt Dillon's DICE, and the source code is
  95. geared toward that compiler.  SAS users will have to perform surgery
  96. to make it work, I know.  I tried and gave up becasue I hate SAS
  97. anyway.  Aztec users might have to do cosmetic stuff.  GCC works fine;
  98. just be sure you've either #defined of -D-defined GCC.
  99.  
  100. This stuff, binary and source, is public domain.  I release all
  101. liability for damages brought about by usage at just the wrong time of
  102. day in La Paz, or whatever else could cause a problem, along with
  103. rights to the code.  It's everyone's now.
  104.